<?php
    if( isset( $errorsModel ) && $errorsModel instanceof ErrorsModelVO )
    {
        $manager = new ErrorsModelManager( $errorsModel );
    }
    if( !isset($result) || !$result instanceof UserVO ) $result = new UserVO();
?>
<div id="title_bloc">
    <h1>Gestion des applications Flash <strong>: USERS</strong></h1>
</div>

<div id="description_bloc">
    Formulaire d'ajout d'un utilisateur.
</div>

<?php $this->config->includePartial( BackendModulesList::MAIN, 'flashes', array( 'flashes' => $flashes ) ) ;?>

<form action="<?php echo UriHelper::get( BackendModulesList::USERS, BackendActionsList::ADD ) ;?>" method="post" >
    <label for="roleID">Role</label><?php echo HtmlHelper::select( UserModel::ROLE_ID_FIELD, $list, array( 'id' => 'roleID' ), true, $result->roleID ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( UserModel::ROLE_ID_FIELD ) ) echo HtmlHelper::errorForm( $manager->getError(  UserModel::ROLE_ID_FIELD )->message ) . '<br />' ;?>

    <label for="firstName">FirstName</label><?php echo HtmlHelper::inputText( UserModel::FIRST_NAME_FIELD, array( 'id' => 'firstName', 'value' => $result->firstName ) ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( UserModel::FIRST_NAME_FIELD ) ) echo HtmlHelper::errorForm( $manager->getError(  UserModel::FIRST_NAME_FIELD )->message ) . '<br />' ;?>

    <label for="lastName">LastName</label><?php echo HtmlHelper::inputText( UserModel::LAST_NAME_FIELD, array( 'id' => 'lastName', 'value' => $result->lastName ) ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( UserModel::LAST_NAME_FIELD ) ) echo HtmlHelper::errorForm( $manager->getError(  UserModel::LAST_NAME_FIELD )->message ) . '<br />' ;?>

    <label for="userName">UserName</label><?php echo HtmlHelper::inputText( UserModel::USER_NAME_FIELD, array( 'id' => 'userName', 'value' => $result->userName ) ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( UserModel::USER_NAME_FIELD ) ) echo HtmlHelper::errorForm( $manager->getError(  UserModel::USER_NAME_FIELD )->message ) . '<br />' ;?>

    <label for="email">Email</label><?php echo HtmlHelper::inputText( UserModel::EMAIL_FIELD, array( 'id' => 'email', 'value' => $result->email ) ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( UserModel::EMAIL_FIELD ) ) echo HtmlHelper::errorForm( $manager->getError(  UserModel::EMAIL_FIELD )->message ) . '<br />' ;?>

    <label for="password">Password</label><?php echo HtmlHelper::password( UserModel::PASSWORD_FIELD, array( 'id' => 'password' ) ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( UserModel::PASSWORD_FIELD ) ) echo HtmlHelper::errorForm( $manager->getError(  UserModel::PASSWORD_FIELD )->message ) . '<br />' ;?>

    <label for="block">Block ?</label><?php echo HtmlHelper::checkbox( UserModel::BLOCK_FIELD, array( 'id' => 'block' ), $result->block == true ) ?><br />
    <?php if( isset( $manager ) && $manager->hasError( UserModel::BLOCK_FIELD ) ) echo HtmlHelper::errorForm( $manager->getError(  UserModel::BLOCK_FIELD )->message ) . '<br />' ;?>

    <span class="submit"><?php echo HtmlHelper::submit( array( 'name' => 'submit', 'value' => 'Ajouter un utilisateur' ) ) ; ?></span>
</form>